package com.mt.baseinfo.service.kafka;

import com.mt.baseinfo.controller.KafkaProducerController;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
public class JavaKafkaConfigurer {
    private static Properties properties;
    public synchronized static Properties getKafkaProperties() {
        if (null != properties) {
            return properties;
        }
        //获取配置文件kafka.properties的内容。
        Properties kafkaProperties = new Properties();
        try {
            kafkaProperties.load(KafkaProducerController.class.getClassLoader().getResourceAsStream("kafka.properties"));
        } catch (Exception e) {
            //没加载到文件，程序要考虑退出。
            e.printStackTrace();
        }
        properties = kafkaProperties;
        return kafkaProperties;
    }
}
